<template>
<!--  添加子设备-->
  <div>
    <el-dialog 
      title="添加子设备"
      :visible.sync="dialogTableVisible"
      :close-on-click-modal="false"
      :before-close="close"
      :modal-append-to-body="true"
      :append-to-body="true"

      width="950px">
      <el-form :model="selectForm" ref="selectForm" :inline="true">
        <el-form-item label="设备编号" >
          <el-input
            v-model="selectForm.deviceCode"
            placeholder="请输入设备编号"
            clearable
            size="small"
            @keyup.enter.native="getList"
          />
        </el-form-item>
        <el-form-item label="设备名称" >
          <el-input
            v-model="selectForm.deviceName"
            placeholder="请输入设备名称"
            clearable
            size="small"
            @keyup.enter.native="getList"
          />
        </el-form-item>
        <el-form-item label="类型" >
          <el-select v-model="selectForm.parentId" placeholder="请选择" @keyup.enter.native="getList">
            <el-option
              v-for="item in type"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="list.rows" stripe
                @selection-change="currentChange">
        <el-table-column type="selection" width="55" />
        <el-table-column align="center" type="index" label="序号"  width="55"  />
        <el-table-column align="center" label="设备编号" property="deviceCode"  ></el-table-column>
        <el-table-column align="center" label="设备名称"   property="deviceName" :show-overflow-tooltip="true"  ></el-table-column>
        <el-table-column align="center" label="设备品牌" property="deviceBrandsName" :show-overflow-tooltip="true"  ></el-table-column>
        <el-table-column align="center" label="规格型号"  property="deviceModel"  ></el-table-column>
      </el-table>
      <pagination
        :total="list.total?list.total:0"
        :page.sync="selectForm.pageNum"
        :limit.sync="selectForm.pageSize"
        @pagination="getList"
      />
      <span slot="footer" class="dialog-footer">
        <el-button type="primary"  size="mini" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import  {listSubSet} from '@/api/device/index'
  import { treeselect } from "@/api/system/dept";
  export default {

    data() {
      return {
        loading:false,
        list:[],
        dialogTableVisible:true,

        //产品查询数据
        selectForm:{
          deviceCode:'',
          deviceName:'',
          parentId:'',
          pageNum: 1,
          pageSize: 10,
        },
        //类型数据
        type:[
          {value:0,label:'无父设备的设备'},
          {value:'',label:'所有设备'},
        ],
        selectData:[],

        newxuanz:[],//当前选中的
        deptOptions:[],//树形图数据
        defaultProps: {
          children: "children",
          label: "label"
        },
        //产品列表数据
        chanpinList:[
          {code:'HC2018121300111',name:'运输车',danwei:'辆',fenlei:'车辆'},
          {code:'HC2018121300112',name:'运输车',danwei:'辆',fenlei:'车辆'},
          {code:'HC2018121300113',name:'运输车',danwei:'辆',fenlei:'车辆'},
          {code:'HC2018121300114',name:'运输车',danwei:'辆',fenlei:'车辆'}
        ],

      };
    },
    components:{

    },
    created() {
      this.getList();
    },
    methods: {
      async getList(){
        this.loading = true
        this.list=[]
        let res=await listSubSet(this.selectForm)
        this.list=res
        this.loading = false
      },
      close(){
        this.$emit('subSetChane')
      },
      currentChange(val){
        console.log(val);
        this.selectData=val
      },
      submit(){
        if(this.selectData){
          this.$emit('subSetChane',this.selectData)
        }
      },

    }
  };
</script>
<style >





</style>
